#!/bin/bash

usage() {
    echo "Usage: $(basename $0) name version"
}

if [ $# -lt 2 ]; then
    usage
    exit 1
fi

scriptdir="$(dirname "$0")"
name="$1"; shift
version="$1"; shift
files="$*"
if [ -z "$files" ]; then
    files=$($scriptdir/list-source-files)
    if [ -e build_mode ]; then
	files="${files} build_mode"
    fi
fi

tar --owner=root --group=root --transform="s|^|$name-$version/|" \
  -cjf $name-$version.tar.bz2 $files &&
ls -l $name-$version.tar.bz2
